<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------
namespace app\api\validate\wddj\usert;

use think\Validate;

class UserRealNameAuthentication extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name'=>'require',
        'id_card'=>'require|checkIdCard',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'name.require'=>'请输入姓名',
        'id_card.require'=>'请输入身份证号',
    ];

    protected function checkIdCard($value,$rule,$data)
    {
        $id_card_pattern = '/^\d{17}[0-9xX]$/';
        if (!preg_match($id_card_pattern, $value)) {
            return "身份证号码格式不正确！";
        }
        return true;
    }
    
}
